<%@page import="com.glowdayz.common.DBHandler"%>
<%@page import="java.util.ArrayList"%>
<%@ page import="com.glowdayz.glowmee.dao.SecondCategoryDAO"%>
<%@ page import="com.glowdayz.glowmee.cmd.SecondCategoryCMD"%>
<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%
	String first = request.getParameter("first");

	if (first.equals("default")) {
	%>
<?xml version="1.0" encoding="utf-8" ?>
<second>
	<item>
		<idSecondCategory>default</idSecondCategory>
		<secondCategoryText>- 1차를 먼저 선택하여 주세요 -</secondCategoryText>
	</item>
</second>
	<%	
		return;
	}
	DBHandler.getInstance().connect();
	SecondCategoryDAO dao = SecondCategoryDAO.getInstance();
	ArrayList<SecondCategoryCMD> cmd = dao.getSecondCategoryList(1, -1, "idFirstCategory=" + first + " AND isDisplay=1");
	if (cmd != null) {
%>
<?xml version="1.0" encoding="utf-8" ?>
<second>
	<item>
		<idSecondCategory>default</idSecondCategory>
		<secondCategoryText>- 2차카테고리 -</secondCategoryText>
	</item>
	<%
		for (int i=0; i<cmd.size(); i++) {
			SecondCategoryCMD temp = cmd.get(i);
	%>
	<item>
		<idSecondCategory><%= temp.getIdSecondCategory() %></idSecondCategory>
		<secondCategoryText><%= temp.getSecondCategoryText() %></secondCategoryText>
	</item>
	<%
		}
		DBHandler.getInstance().disconnect();
	%>
</second>
<%
	} else {
%>
<?xml version="1.0" encoding="utf-8" ?>
<second>
	<item>
		<idSecondCategory>default</idSecondCategory>
		<secondCategoryText>- 해당 2차 카테고리 데이터없음 -</secondCategoryText>
	</item>
</second>
<%}%>